//
//  FirstViewController.m
//  mumegui
//
//  Created by Niels Buekers on 09/11/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "genreViewController.h"
#import "cwRadioAppDelegate.h"


@implementation genreViewController
//@synthesize imgRap,imgHouse, imgRock, imgSoundtrack, imgReggae;
@synthesize schermpje;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}


-(void)showBezig:(NSString*)vote{
	HUD = [[MBProgressHUD alloc] initWithView:self.schermpje];
	
    // Add HUD to screen
    [self.schermpje addSubview:HUD];
    // Regisete for HUD callbacks so we can remove it from the window at the right time
    HUD.delegate = self;
    // Show the HUD while the provided method executes in a new thread
	NSString * txt = @"Processing ";
	txt = [txt stringByAppendingString:vote];
	txt = [txt stringByAppendingString:@" vote"];
	HUD.labelText = txt;
    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];	
	
}

- (void)myTask {
    // Do something usefull in here instead of sleeping ...
//    sleep(3);
	[NSThread sleepForTimeInterval:1.0];
    // Labels can be changed during the execution
    HUD.detailsLabelText = @"Sending..";
	[NSThread sleepForTimeInterval:0.5];
}
- (void)hudWasHidden {
    [HUD removeFromSuperview];
    [HUD release];
}

//accessing the delegate to process a vote
-(IBAction) voteRock{
	cwRadioAppDelegate *appDelegate = (cwRadioAppDelegate *)[[UIApplication sharedApplication] delegate];
	[appDelegate voteGenre:@"rock"]; 
	[self showBezig:@"rock"];
}

-(IBAction) voteSoundtrack{
	cwRadioAppDelegate *appDelegate = (cwRadioAppDelegate *)[[UIApplication sharedApplication] delegate];
	[appDelegate voteGenre:@"soundtrack"];; 
	[self showBezig:@"Soundtrack"];
}

-(IBAction) voteReggae{
	cwRadioAppDelegate *appDelegate = (cwRadioAppDelegate *)[[UIApplication sharedApplication] delegate];
	[appDelegate voteGenre:@"reggae"];
	[self showBezig:@"reggae"];
}

-(IBAction) voteHipHop{
	cwRadioAppDelegate *appDelegate = (cwRadioAppDelegate *)[[UIApplication sharedApplication] delegate];
	[appDelegate voteGenre:@"hiphop"]; 
	[self showBezig:@"hiphop"];
}

-(IBAction) voteMetal{
	cwRadioAppDelegate *appDelegate = (cwRadioAppDelegate *)[[UIApplication sharedApplication] delegate];
	[appDelegate voteGenre:@"metal"];
	[self showBezig:@"metal"];
}

-(IBAction) voteClassic{
	cwRadioAppDelegate *appDelegate = (cwRadioAppDelegate *)[[UIApplication sharedApplication] delegate];
	[appDelegate voteGenre:@"classic"];
	[self showBezig:@"classic"];
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
